package com.huicoo.forestmanager.util;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * json管理
 *
 * @author Administrator
 */
public class JsonUtils {
    private static Gson gson = new Gson();

    public static <T> T fromJson(String json, Class<T> classOfT) {
        return gson.fromJson(json, classOfT);
    }

    public static String toJson(Object param) {
        return gson.toJson(param);
    }

    public static JSONObject toJSONObject(Object map) {
        String json = gson.toJson(map);
        try {
            return new JSONObject(json);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
